from pydantic import BaseModel, Field
from typing import List, Dict
from datetime import datetime


class User_Login(BaseModel):
    uUserName: str = Field(..., description="用户名")
    uPassword: str = Field(..., description="密码")


class UserInfo(BaseModel):
    name: str
    gender: str
    age: int
    weight: float
    height: float

class RegisterRequest(BaseModel):
    id: str
    password: str
    name: str
    gender: str
    age: int
    weight: float
    height: float

class User_Pwd_Update(BaseModel):
    oldPassword: str = Field(..., description="旧密码")
    newPassword: str = Field(..., description="新密码")


class ChatBody(BaseModel):
    body: str
    type: bool
    gender: str
    age: int
    weight: float
    height: float



class UserCaloriesResponse(BaseModel):
    """用户热量统计响应模型"""

    totalIntake: int
    targetIntake: int


class MealsResponse(BaseModel):
    """获取餐食记录响应模型"""

    meals: Dict[
        str, List[int]
    ]  # 每个餐次包含的食物列表，例如 {"早餐": ["鸡蛋", "牛奶"], "午餐": ["米饭", "蔬菜"]}


class SearchFoodResponse(BaseModel):
    """搜索食物响应模型"""

    food_name: str  # 食物名称
    calories: int  # 食物的热量


# 定义数据库模型
class Category(BaseModel):
    id: int
    name: str


class Food(BaseModel):
    id: int
    name: str
    category: str
    calories: float
    unit: str
    protein: float
    fat: float
    carbs: float
    img_url: str


class MealRecord(BaseModel):
    food_name: str  # 食物 ID
    meal_type: str  # 餐次类型，例如 "早餐"、"午餐"、"晚餐"、"加餐"
    entry_time: datetime  # 记录时间
    weight: float  # 食物重量（克）
    calories: float  # 食物热量
    protein: float  # 食物蛋白质含量
    carbs: float  # 食物碳水化合物含量
    fat: float  # 食物脂肪含量
